/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.kz.shange.security;

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.kz.shange.common.KzTemplate;
import org.kz.shange.models.Author;

/**
 *
 * @author Administrator
 */
@ManagedBean(name = "navMgr")
@RequestScoped
public class NavMgr extends KzTemplate implements Serializable {

    private String btnDisplay_share;
    private String btnDisplay_logon;
    private String btnDisplay_userName;
    private String userName;
    private String userId;

    public String getBtnDisplay_share() {
        btnDisplay_share = super.getPrivilege()== PV_MEMBER ? "block" : "none";
        return btnDisplay_share;
    }

    public String getBtnDisplay_logon() {
        btnDisplay_logon = super.getPrivilege() == PV_VISITOR ? "block" : "none";
        return btnDisplay_logon;
    }

    public String getBtnDisplay_userName() {
        btnDisplay_userName = super.getPrivilege() == PV_MEMBER ? "block" : "none";
        return btnDisplay_userName;
    }

    public String getUserName() {
        Author a = super.getLoginUser();
        this.userName = (a == null) ? "游客" : a.getName();
        return userName;
    }

    public String getUserId() {
        Author a = super.getLoginUser();
        this.userId = (a == null) ? "-1" : a.getId();
        return userId;
    }    
    
}
